package com.blog.back.config;

import com.blog.back.redis.RedisUtils;
import com.blog.back.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author codeDorado
 * @version 1.0
 * @date 2020/8/16 16:57
 * 用作定时任务，每次都把每天的前三点击量的刷到redis中
 */
@Component
@EnableScheduling
@EnableAsync
public class MultithreadScheduleTask {

    @Autowired
    ArticleService articleService;

    @Value("${user.IdA}")
    Long idA;

    @Value("${user.IdB}")
    Long idB;

    @Async
    @Scheduled(fixedDelay = 1000 * 60 * 60 * 24)
    public void flashMoreArticleEveryDayA() {
        articleService.selectScheduled(idA);
    }


    @Async
    @Scheduled(fixedDelay = 1000 * 60 * 60 * 24)
    public void flashMoreArticleEveryDayB() {
        articleService.selectScheduled(idB);
    }
}
